package tool.gzzz.util;

import cn.hutool.core.util.HexUtil;
import cn.hutool.crypto.symmetric.SM4;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class SM4Util_Str {
    private static  final String SM4_ALGORITHM = "81c1e4f317a51d84ec7099620ff1a776";
    private SM4 sm4;
    //加密
    public  String encryptSM4(String content){
        sm4 = new SM4(HexUtil.decodeHex(SM4_ALGORITHM));
        return sm4.encryptHex(content.getBytes(StandardCharsets.UTF_8));
    }
    //解密
    public  String decryptM4(String content){
        sm4 = new SM4(HexUtil.decodeHex(SM4_ALGORITHM));
        return sm4.decryptStr(content);
    }

}
